package demo3;

import lombok.AllArgsConstructor;
import lombok.Data;

public class ProductorConsumer {

    public static void main(String[] args) {
        SynContainer synContainer = new SynContainer();
        new Productor(synContainer).start();
        new Consumer(synContainer).start();
    }

}
@Data
@AllArgsConstructor
class Chicken {
    private Integer id;
}

class Productor extends Thread{
    SynContainer synContainer;
    public Productor(SynContainer synContainer) {
        this.synContainer = synContainer;
    }

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
                synContainer.pushTo(new Chicken(i));
        }
    }
}

class Consumer extends Thread{
    SynContainer synContainer;
    public Consumer(SynContainer synContainer){
        this.synContainer = synContainer;
    }

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            synContainer.popTo();
        }
    }
}